import request from './request'

export default {

    async get() {

        let result = {}

        let json = sessionStorage.getItem('payType')

        if (!json) result = await this.set()

        else result = JSON.parse(json)
        
        return result
    },

    async set() {

        const result = await request.get('/common/paytype')

        sessionStorage.setItem('payType', JSON.stringify(result))
    },

    getByName(id){
        const list = this.get()
        return list.find(item => item.id === id).name
    }
}

